/*
 * =====================================================================================
 *
 *       Filename:  data2graph.h
 *
 *    Description:  Change finance data into finance graph
 *
 *        Version:  1.0
 *        Created:  08/06/2009 10:36:33 AM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Zhao Zhao
 *        Company:  NDSSL@VT
 *
 * =====================================================================================
 */
#pragma once

#include "../share/include.h"
#include "../share/arg.h"

using namespace std;

typedef struct
{
	float open;
	float close;
	float low;
	float high;
	long int volume;

}StockData;

typedef map<string, map<string, StockData> > StockMap;  /* input data (map<name, <date, StockData> >) */
typedef map<string, vector<float> > StockVec;   /* the needed stock time series, such as "return", etc.*/
typedef map<string, vector<string> > StockGraph; /* output graph */
typedef map<string, map<string, float> > CC;    /* correlation coefficient */

class Data2Graph
{
public:
	Data2Graph(const char* configFile);         /* parsing config file */
	~Data2Graph(void);
	void Processing();                          /* read data, change to graph, output, etc. */
private:
	Arg* arg;                                   /* parsing config file class */
	StockMap 	stockMap;
	StockGraph	stockGraph;
	StockVec	stockVec;
	CC			stockCC;
	//begin and end dates for calculating correlation coefficient 
	int beginDate;
	int endDate; 
	short stockNum;                             /* # of stocks */
	
	
	void ReadData(const char* fData);           /* read data from original file */
	void GenerateDataVec();                     /* generate needed time series of stocks, currently to be "return" */
	void CalcCCMatrix();                        /* calculate full cc matrix */
	void GenerateGraph();                       /* generate financial graph and output */
	vector<string> TokenLine(char* line);        /* token a line to vector of strings */
};


